from common.LoggerUtil import log
import unittest


class assertUtils:
    def assertEquals(self, actual, expected):
        """
        断言是否等于
        :param actual: 实际值
        :param expected: 预期值
        :return:
        """
        try:
            self.assertEquals(str(actual), str(expected))
            log.info("断言成功,实际值：{} 等于 预期值：{}".format(actual, expected))
        except AssertionError as e:
            log.error("断言失败,实际值：{} 不等于 预期值：{}".format(actual, expected))
            raise AssertionError

    def assertTrue(self, actual):

        """
        断言是否为真
        :param actual: 实际值
        :return:
        """
        try:
            assert actual == True
            log.info("断言成功,实际值：{} 为真".format(actual))
        except AssertionError as e:
            log.error("断言失败,实际值：{} 不为真".format(actual))
            raise AssertionError

    def assertIn(self, content, target):
        """
        断言是否包含
        :param content: 包含文本
        :param target: 目标文本
        :return:
        """
        try:
            assert content in target
            log.info("断言成功,目标文本：{} 包含 文本：{}".format(target, content))
        except AssertionError as e:
            log.error("断言失败,目标文本：{} 不包含 文本：{}".format(target, content))
            raise AssertionError
